#include "ZContainer.h"
#pragma once
namespace Zdib
{
	class CAllRoot;
	class CImager:public CContainer
	{
	public:
		CImager(CContainer *root,CContainer *parent,char *filename);
		virtual ~CImager();

		bool SetDirFrame(BYTE dir,BYTE frame)
		{
			bool is;
			this->m_AllDir=dir;
			this->m_AllFrame=frame;
			if(m_Imgs)
			{
				is=m_Imgs->SetDirFrame(dir,frame);
				if(is)
				{
					W=m_Imgs->W;
					H=m_Imgs->H;
				}
				return is;
			}
			return false;
		};
		void SetCurFrame(BYTE frame)
		{
			if(frame>=m_AllFrame)
			{
				if(m_AllFrame==0)
					m_CurFrame=0;
				else
					m_CurFrame=m_AllFrame-1;
			}
			else
				m_CurFrame=frame;
		};
		void SetCurDir(BYTE dir)
		{
			if(dir>=m_AllDir)
			{
				if(m_AllDir==0)
					m_CurDir=0;
				else
					m_CurDir=m_AllDir-1;
			}
			else
				m_CurDir=dir;
		};

		BYTE GetCurFrame()
		{
			if(m_Imgs)
				return m_CurFrame;
			else
				return 0;
		};
		BYTE GetCurDir()
		{
			if(m_Imgs)
				return m_CurDir;
			else
				return 0;
		};
		BYTE GetAllFrame()
		{
			if(m_Imgs)
				return m_AllFrame;
			else
				return 0;
		};
		BYTE GetAllDir()
		{
			if(m_Imgs)
				return m_AllDir;
			else
				return 0;
		};
		CBitBmp *GetCurBmp();
		virtual void Draw();

		virtual CBitBmp *GetMyImg(){return GetCurBmp();};
		virtual bool isInMyScope(int x,int y);
		virtual bool OnEvent(const TEvent& ev);
	protected:
		BYTE m_AllFrame;
		BYTE m_AllDir;
		BYTE m_CurFrame;
		BYTE m_CurDir;
		CSpiritImgFile *m_Imgs;
	};

	class CCutImager:public CImager
	{
	public:
		CCutImager(CContainer *root,CContainer *parent,char *filename):CImager(root,parent,filename)
		{}
		~CCutImager()
		{}
		void SetSize(int w,int h);
		virtual void Draw();
		virtual bool isInMyScope(int x,int y);
	};
}
